package com.zxc.project.base;

import com.zxc.project.pojo.enums.system.DataStateEnum;
import lombok.Data;

import java.time.LocalDateTime;

@Data
public class BaseEntity {

    //主键id
    protected Long id;

    //创建时间
    protected LocalDateTime createTime;

    //更新时间
    protected LocalDateTime updateTime;

    //是否删除状态
    protected DataStateEnum deleted;

    public void init() {
        init(false);
    }

    public void init(boolean setUpdateTime) {
        this.createTime = LocalDateTime.now();
        this.deleted = DataStateEnum.NORMAL;
        if(setUpdateTime) {
            this.updateTime = this.getCreateTime();
        }
    }
}
